package com.fly.common.persistence;

import com.fly.modules.sys.entity.User;

import java.io.Serializable;

/**
 * Created by SWan on 2017/4/26.
 * Entity基础类
 */
public abstract class BaseEntity<T> implements Serializable{

    /**
     * 当前实体分页对象
     */
    protected Page<T> page;
    /**
     * 删除标记（0：正常；1：删除；2：审核；）
     */
    public static final String DEL_FLAG_NORMAL = "0";
    public static final String DEL_FLAG_DELETE = "1";
    public static final String DEL_FLAG_AUDIT = "2";

    public BaseEntity() {
    }

    public BaseEntity(Integer id) {
        this.id = id;
    }

    public Page<T> setPage(Page<T> page) {
        this.page = page;
        return page;
    }

    /**
     * 实体编号（唯一标识）
     */
    protected Integer id;

    /**
     * 当前用户
     */
    protected User currentUser;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public User getCurrentUser() {
        return currentUser;
    }

    public void setCurrentUser(User currentUser) {
        this.currentUser = currentUser;
    }

    /**
     * 插入之前执行方法，子类实现
     */
    public abstract void preInsert();

    /**
     * 更新之前执行方法，子类实现
     */
    public abstract void preUpdate();

}
